home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / src / out-of-phase-102-c / OutOfPhase 1.02 Source / OutOfPhase Folder / Fractions.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-23  |  1.7 KB  |  53 lines  |  [TEXT/KAHL]

  1. /* Fractions.h */
  2.  
  3. #ifndef Included_Fractions_h
  4. #define Included_Fractions_h
  5.  
  6. /* Fractions module depends on */
  7. /* MiscInfo.h */
  8. /* Audit */
  9. /* Debug */
  10. /* Definitions */
  11. /* Factoring */
  12.  
  13. /* note: this module does NOT deal with negative numbers!!! */
  14.  
  15. typedef struct FractionRec
  16.     {
  17.         unsigned long        Integer;
  18.         unsigned long        Fraction;
  19.         unsigned long        Denominator;
  20.     } FractionRec;
  21.  
  22. /* convert a decimal number to a fraction with the specified denominator limit */
  23. void                                Double2Fraction(double Value, unsigned long Denominator,
  24.                                             FractionRec* Fraction);
  25.  
  26. /* convert fraction to a double */
  27. double                            Fraction2Double(FractionRec* Fraction);
  28.  
  29. /* add fractions.  Destination fraction can be one of the source fractions */
  30. void                                AddFractions(FractionRec* Left, FractionRec* Right, FractionRec* Dest);
  31.  
  32. /* test to see if the left is greater than the right */
  33. MyBoolean                        FracGreaterThan(FractionRec* Left, FractionRec* Right);
  34.  
  35. /* test to see if the left is greater than or equal to the right */
  36. MyBoolean                        FracGreaterEqual(FractionRec* Left, FractionRec* Right);
  37.  
  38. /* test fractions for equality */
  39. MyBoolean                        FractionsEqual(FractionRec* Left, FractionRec* Right);
  40.  
  41. /* reduce fraction */
  42. void                                ReduceFraction(FractionRec* Frac);
  43.  
  44. /* multiply fractions.  destination can be one of the sources */
  45. /* this function will fail on numbers considerably smaller than the */
  46. /* range of representable fractions. */
  47. void                                MultFractions(FractionRec* Left, FractionRec* Right, FractionRec* Dest);
  48.  
  49. /* subtract second fraction from first.  Destination can be one of the sources */
  50. void                                SubFractions(FractionRec* Left, FractionRec* Right, FractionRec* Dest);
  51.  
  52. #endif
  53.